/**
 * admui-basic v2.1.0 (http://www.admui.com/)
 * Copyright 2015-2019 Admui Team
 * Licensed under the Admui License 1.1 (http://www.admui.com/about/license)
 */
(function(window, document, $) {
  'use strict';

  window.App.extend({
    run: function() {
      var table;
      // 安装 - 在foot每个单元格中添加文本框
      $('#dataTableExample tfoot th').each(function() {
        var title = $('#dataTableExample thead th')
          .eq($(this).index())
          .text();
        $(this).html('<input class="form-control" type="text" placeholder="查找 ' + title + '">');
      });

      // DataTable
      table = $('#dataTableExample').DataTable($.concatCpt('dataTable'));

      // 查找
      table
        .columns()
        .eq(0)
        .each(function(colIdx) {
          $('input', table.column(colIdx).footer()).on('keyup change', function() {
            table
              .column(colIdx)
              .search(this.value)
              .draw();
          });
        });
    }
  });

  window.App.run();
})(window, document, jQuery);
